package com.example.onlinemonitoring.dao;

import com.example.onlinemonitoring.Util.tem.MyMapper;
import com.example.onlinemonitoring.model.Newblqsensor;
import com.example.onlinemonitoring.model.common.ptconfig;
import com.example.onlinemonitoring.model.common.wsdconfig;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface NewblqsensorMapper extends MyMapper<Newblqsensor> {
    wsdconfig selectwsd(Newblqsensor record);

    List<ptconfig> selectpt(Newblqsensor record);

    @Update({ "update newblqsensor", "set ptaddr = null", "where stationid=#{stationid}",
            "and devicegroup=#{devicegroup}", "and ptaddr = #{ptaddr}" })
    int setPtaddr(Integer stationid, Integer devicegroup, Integer ptaddr);

    @Update({ "update newblqsensor", "set wsdaddr = #{wsdaddr}", "where id=#{id}" })
    int setWsdaddr(Integer wsdaddr, Long id);

    @Delete("DELETE FROM newblqhistory WHERE datatime < DATE_SUB(NOW(), INTERVAL 1 WEEK)")
    void deleteRecordsBeforeOneWeek();
}